*************************************************************************************
* Figure A.4
*************************************************************************************

use  "Data_temp/turnout.dta", clear
snapshot erase _all
tab election, gen(elec_dummy)
forvalues x = 4/6 {
	dis `x'
	tab election if inrange(age`x',-24,23)
	}

global elec4		elec_dummy2-elec_dummy6
global elec5		elec_dummy1 elec_dummy3-elec_dummy6
global elec6		elec_dummy1-elec_dummy2 elec_dummy4-elec_dummy6

snapshot erase _all
snapshot save



cap program drop  elec_app

program def elec_app

	snapshot restore 1

	
	rdrobust voted age`1' if age`1'!=0, covs(${elec`1'}) p(1)  h(24)
	global se=round(e(se_tau_cl),.001)
	global coef=round(e(tau_cl),.001)
	global obs`1'=e(N_b_l)+e(N_b_r)
	
	
	collapse (mean) voted (count) counter=voted if inrange(age`1',-24,24), by(age`1')
	
	twoway (scatter voted age`1' if age`1'<0, color(edkblue) ///
		msymbol(Oh) msize(medlarge)) ///
	(lfit voted age`1' if age`1'<0, color(edkblue) msymbol(Oh)) ///
	(scatter voted age`1' if age`1'>0, color(edkblue) mlwidth(medthick) ///
		msymbol(Oh) msize(medlarge)) ///
	(lfit voted age`1' if age`1'>0, color(edkblue) mlwidth(medthick) ///
		msymbol(Oh)), ///
	yt("Share voted", size(medlarge)) yl(0.0(0.2)1) xt("Relative age in months to cut-off") xl(-24(6)24) ////
	xline(0, lcolor(gs12)) ///
	legend(off) graphregion(margin(zero)) xt(, size(medlarge)) ///
	text(0.1 12 "RD estimate: $coef ($se)")
	

	graph export "Figures/a_fg5_`2'.eps", replace

end
* Appendix Figure A.5
*			* Election	File name
elec_app	4			a
elec_app	5			b
elec_app	6			c
